Completed
Push — master ( c7ea8a...8a62cc )
by Justin
01:44
created

module.exports   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 84

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
c 2
b 0
f 1
nc 1
nop 1
dl 0
loc 84
rs 8.7169

6 Functions

Rating   Name   Duplication   Size   Complexity  
A 0 7 2
A 0 3 1
A 0 6 2
A 0 3 1
A 0 4 1
A 0 5 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/**
2
 * RS extensions to Person
3
 */
4
module.exports = function(GedcomX){
5
  
6
  // Extend serialization properties
7
  GedcomX.Person.jsonProps.push('living', 'display');
8
  
9
  // Override init() so that we can deserialize normalized values
10
  var oldInit = GedcomX.Person.prototype.init;
11
  GedcomX.Person.prototype.init = function(json){
12
    oldInit.call(this, json);
13
    if(json){
14
      this.setLiving(json.living);
15
      this.setDisplay(json.display);
16
    }
17
  };
18
  
19
  /**
20
   * Set the living flag
21
   * 
22
   * @function setLiving
23
   * @instance
24
   * @memberof Person
25
   * @param {Boolean} living
26
   * @return {Person} this
27
   */
28
  GedcomX.Person.prototype.setLiving = function(living){
29
    this.living = living;
30
    return this;
31
  };
32
  
33
  /**
34
   * Get the living flag
35
   * 
36
   * @function getLiving
37
   * @instance
38
   * @memberof Person
39
   * @return {Boolean} living
40
   */
41
  GedcomX.Person.prototype.getLiving = function(){
42
    return this.living;
43
  };
44
  
45
  /**
46
   * Set the display properties
47
   * 
48
   * @function setDisplay
49
   * @instance
50
   * @memberof Person
51
   * @param {DisplayProperties} display
52
   * @return {Person} this
53
   */
54
  GedcomX.Person.prototype.setDisplay = function(display){
55
    if(display){
56
      this.display = GedcomX.DisplayProperties(display);
57
    }
58
    return this;
59
  };
60
  
61
  /**
62
   * Get the display properties
63
   * 
64
   * @function getDisplay
65
   * @instance
66
   * @memberof Person
67
   * @return {DisplayProperties}
68
   */
69
  GedcomX.Person.prototype.getDisplay = function(){
70
    return this.display;
71
  };
72
  
73
  /**
74
   * Get a person's preferred name, if one exists.
75
   * 
76
   * @function getPreferredName
77
   * @instance
78
   * @memberof Person
79
   * @return {Name}
80
   */
81
  GedcomX.Person.prototype.getPreferredName = function(){
82
    return this.getNames().find(function(n){
83
      return n.getPreferred();
84
    });
85
  };
86
  
87
};